<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试：动态的v-on</title>
    <!-- 从根目录下访问vue.js -->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript">
        Vue.config.productionTip = false  //阻止 vue 在启动时生成生产提示。
    </script>
</head>

<body>
    <div id="app">
        <button v-on:[event1]="test1">click按下弹起事件</button>
        <button v-on:[event2]="test2">focus按下事件</button>
    </div>
</body>

</html>



<script type="text/javascript">
    new Vue({
        el: "#app",
        data: {
            event1: "click",
            event2: "focus",
        },
        methods: {
            test1(){
                console.log("按下然后弹起了")
            },
            test2(){
                console.log("按下了")
            }
        }
    })
</script>